﻿using System.Xml.Linq;
using Lightray.Hattrick.ChppLib.EntityTypes;

namespace Lightray.Hattrick.ChppLib
{
    public class MatchArenaStats
    {
        public int ArenaID { get; private set; }
        public string ArenaName { get; private set; }
        public Weather Weather { get; private set; }
        public int Attendance { get; private set; }
        public int SoldTerraces { get; private set; }
        public int SoldBasic { get; private set; }
        public int SoldRoof { get; private set; }
        public int SoldVIP { get; private set; }

        protected MatchArenaStats() { }

        public static MatchArenaStats FromXml(XElement matchArenaNode)
        {
            HattrickXmlReader reader = new HattrickXmlReader(matchArenaNode);
            return new MatchArenaStats()
            {
                ArenaID = reader.ReadNumber("ArenaID"),
                ArenaName = reader.ReadString("ArenaName"),
                Weather = reader.ReadWeather("WeatherID"),
                Attendance = reader.ReadNumber("SoldTotal"),
                SoldTerraces = reader.ReadNumber("SoldTerraces"),
                SoldBasic = reader.ReadNumber("SoldBasic"),
                SoldRoof = reader.ReadNumber("SoldRoof"),
                SoldVIP = reader.ReadNumber("SoldVIP")
            };
        }

        public override string ToString()
        {
            return ArenaName + " Attendance: " + Attendance;
        }
    }
}
